package cn.strive.eams.building.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.building.pojo.dto.BuildQuery;
import cn.strive.eams.building.pojo.dto.BuildingSaveParam;
import cn.strive.eams.building.pojo.vo.BuildVO;
import cn.strive.eams.building.service.BuildService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/building")
@Api(tags = "建筑管理")
public class BuildController {
    @Autowired
    BuildService buildService;
    @GetMapping("/select")
    public JsonResult selectBuild(BuildQuery buildQuery) {
        log.debug("查询所有建筑信息:buildQuery={}",buildQuery);
        List<BuildVO> list = buildService.selectBuild(buildQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveBuild(BuildingSaveParam buildingSaveParam) {
        log.debug("保存建筑信息:buildVO={}",buildingSaveParam);
        buildService.saveBuild(buildingSaveParam);
        return JsonResult.ok();
    }
    @DeleteMapping("/delete/{id}")
    public JsonResult deleteBuild(@PathVariable Long id) {
        log.debug("删除建筑信息:id={}",id);
        buildService.deleteBuild(id);
        return JsonResult.ok();
    }
}
